package com.pvdnc.worldmagisk.shell;

import android.util.Base64;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;

public class PacketEncoder extends MessageToByteEncoder<Packet> {

    @Override
    protected void encode(ChannelHandlerContext ctx, Packet msg, ByteBuf out) throws Exception {
        byte[] sendData= Base64.encode(msg.mData, Base64.DEFAULT);
        out.writeInt(msg.mType);
        out.writeInt(sendData.length);
        out.writeBytes(sendData);
        out.writeBytes("\n".getBytes());
    }
}
